package com.zzg.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zzg.base.mapper.BaseMapper;
import com.zzg.base.service.BaseService;

@Service
public abstract class BaseServiceImpl<T> implements BaseService<T> {
	 @Autowired(required = false)
	 private BaseMapper<T> baseMapper;

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean insert(T entity) {
		// TODO Auto-generated method stub
		return  baseMapper.insert(entity) > 0;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean insertSelective(T entity) {
		// TODO Auto-generated method stub
		return baseMapper.insertSelective(entity) > 0;
	}

	@Override
	public boolean insertList(List<T> recordList) {
		// TODO Auto-generated method stub
		return baseMapper.insertList(recordList) > 0;
	}

	@Override
	public boolean deleteById(Object key) {
		// TODO Auto-generated method stub
		return baseMapper.deleteByPrimaryKey(key) > 0;
	}

	@Override
	public T selectById(Object key) {
		// TODO Auto-generated method stub
		return baseMapper.selectByPrimaryKey(key);
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean updateById(T entity) {
		// TODO Auto-generated method stub
		return baseMapper.updateByPrimaryKey(entity) > 0;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean updateSelectiveById(T entity) {
		// TODO Auto-generated method stub
		return baseMapper.updateByPrimaryKeySelective(entity) > 0;
	}

	@Override
	public List<T> listAll() {
		// TODO Auto-generated method stub
		return this.baseMapper.selectAll();
	}

	@Override
	public List<T> select(T record) {
		// TODO Auto-generated method stub
		return this.baseMapper.select(record);
	}

	@Override
	public T selectOne(T record) {
		// TODO Auto-generated method stub
		return this.baseMapper.selectOne(record);
	}
	 
	 
}
